home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
gcc
/
ixemlsrc.lha
/
ixemul
/
general
/
getlogin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-13
|
597b
|
43 lines
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if 0
char *getlogin (void)
{
char *user = getenv("USER");
return user ? user : "amiga";
}
char *cuserid (char *s)
{
char *user = getenv("USER");
if (user == NULL)
user = "amiga";
if (s)
strcpy (s, user);
return s ? s : user;
}
#endif
#include <pwd.h>
#include <unistd.h>
char *cuserid (char *s)
{
struct passwd *pwd;
if ((pwd = getpwuid(geteuid())) == NULL) {
if (s) {
*s = '\0';
return s;
}
}
if (s) {
strncpy(s,pwd->pw_name,L_cuserid);
return s;
}
return pwd->pw_name;
}